package com.itheima.stringtest;

import java.util.Scanner;

public class Test7 {
    public static void main(String[] args) {
        //需求：以字符串的形式从键盘接受一个手机号，将中间四位号码屏蔽
        //最终效果为：`131****9468`
        //1.键盘录入
        Scanner sc = new Scanner(System.in);
        String phoneNumber = "";
        while (true) {
            System.out.println("请输入一个手机号码");
            phoneNumber = sc.next();
            if (phoneNumber.length() == 11) {
                break;
            } else {
                System.out.println("您输入的手机号码有误，请重新输入");
            }
        }
        //System.out.println(phoneNumber);
        String start = phoneNumber.substring(0, 3);
        String end=phoneNumber.substring(7);
        phoneNumber=start+"****"+end;
        System.out.println(phoneNumber);
    }
}
